package reflect;

import reflect.annotations.AutoRunMethod;

import java.lang.reflect.Method;

public class ReflectDemo13 {
    public static void main(String[] args) throws Exception {
        //获取Person类中doSome方法的注解@AutoRunMethod上的参数
        Class cls = Class.forName("reflect.Person");
        Method method = cls.getDeclaredMethod("doSome");
        //判断该方法是否被注解@AutoRunMethod标注
        if (method.isAnnotationPresent(AutoRunMethod.class)) {
            //获取注解对象
            AutoRunMethod autoRunMethod = method.getAnnotation(AutoRunMethod.class);
            //获取注解对象的参数
            int value = autoRunMethod.value();
            System.out.println(value);
        }
    }
}
